Actor ShieldRifleSelected : Inventory
{
	inventory.Maxamount 1
}

ACTOR ShieldRifle : BrutalWeapon
{
	Game Doom
	+BLOODSPLATTER
	Weapon.SelectionOrder 3500
	+WEAPON.WIMPY_WEAPON
	+WEAPON.NOAUTOAIM
	+WEAPON.NOALERT
	+WEAPON.CHEATNOTWEAPON
	Weapon.AmmoUse1 0 
	Weapon.AmmoGive1 0 //How much ammo can be gathered with this weapon
	Weapon.AmmoUse2 0
	Weapon.AmmoGive2 0
	Weapon.AmmoType1 "Clip2" //Reserve ammo type
	Weapon.AmmoType2 "RifleAmmo" //Magazine ammo type
	Obituary "%o was drilled by shielded %k's rifle." //Kill message
    AttackSound "None" //You better leave this clear
	//+WEAPON.NOAUTOFIRE
	Inventory.PickupMessage "$GOTRIFLE"
	Inventory.ForbiddenTo BDoomer, Sorcerer, Corvus

	States
	{
	Select:
		SHRI A 0 
		"####" A 0 ACS_NamedExecuteAlways("DinosComboBreaker",0)
		"####" A 0 A_GiveInventory("ShieldRifleSelected",1)
		"####" A 0 A_Giveinventory("GoSpecial",1)
		"####" A 0
		"####" A 0 A_PlaySound("CLIPIN", 1)
		"####" A 0 A_ChangeFlag("SHIELDREFLECT", FALSE)
		"####" A 0 SetPlayerProperty(0,0,0)
		"####" AAAAAAAAAAA 1 A_Raise
		Goto Super::Select
	
	Deselect:
		W02U A 0
		"####" A 0 A_TakeInventory("ShieldRifleSelected",1)
		"####" A 0 A_SetCrosshair(0)
        "####" A 0 A_ZoomFactor(1.0)
		SHRI FEDCBA 1 A_Lower
		Goto Super::Deselect
		
	Fire:
		"####" A 0
		// This was an old trick mark used to allow firing rifles indipendently,
		// this is not possible natively by using ZScript for GZDoom, and is no,
		// longer implemented in SGT_Mark's Brutal DOOM.
		// We are going to be removing it in favor of faster and more responsive
		// behavior.
		//TNT1 A 0 A_JumpIfInventory("FiredPrimary",1,"FireRifle") //Check if player wants to reload
		//SHRI G 1 A_WeaponReady(WRF_NOFIRE)
		//TNT1 A 0 A_JumpIfInventory("FiredPrimary",1,"FireRifle") //Check if player wants to reload
		//TNT1 A 0 A_Refire
		P2W1 A 0 A_GunFlash
		"####" A 0 A_JumpIfInventory("RifleAmmo", 1, 1)//Checks if there is ammo inside the left Rifle
		Goto DryFire2
		"####" A 0 A_AlertMonsters
		"####" A 0 A_FireCustomMissile("Tracer", random(-4,4), 0, 6, -2, 0, random(-2,2))
		RIFF A 0 A_FireCustomMissile("GunFireSmoke", 0, 0, 5, 0, 0, 0)
		"####" A 0 A_PlaySound("weapons/rifle", 1)//Play gun fire sound
	    SHRA B 1 BRIGHT A_FireBullets(5,3,-1,10,"HitPuff",1)//Horizontal Spread, Vertical Spread, Numbers of Projectiles (Leave as -1 if its a single one), Damage Factor
		"####" A 0 A_SetPitch(+0.6 + pitch)//Vertical recoil up
		SHRA C 1 A_FireCustomMissile("RifleCaseSpawn",0,0,20,-10) //Ejetts empty brass
		SHRA C 0 A_SetPitch(-0.6 + pitch)//Vertical recoil down
		SHRA D 1 A_TakeInventory("RifleAmmo", 1)//Remove the fake ammo
		"####" A 0 A_JumpIfInventory("RifleAmmo", 1, 1)//Checks if there is ammo inside the right Rifle
		Goto DryFire2//Couldn't find any ammo. Don't fire.
		SHRA A 1
		Goto ReadyLoop
	
	Ready:
		SHRI ABCDEFG 1
	ReadyLoop:
		"####" A 0 A_SetCrosshair(61)
		"####" A 0 A_JumpIfInventory("Reloading",1,"reload") //Check if player wants to reload
		"####" A 0 A_JumpIfInventory("Kicking",1,"DoKick")
        "####" A 0 A_JumpIfInventory("Taunting",1,"Taunt")
		"####" A 0 A_JumpIfInventory("Salute1", 1, "Salute")
		"####" A 0 A_JumpIfInventory("Salute2", 1, "Salute")
		"####" A 0 A_JumpIfInventory("Unloading",1,"Unload")
		SHRI G 1 A_WeaponReady(WRF_ALLOWRELOAD)
		Loop
		
	NoAmmo:
		"####" A 0
		SHRI G 3 A_PlaySound("weapons/empty", 4)
		"####" A 0 A_JumpIfInventory("Clip2",1,"Reload")
		Goto ReadyLoop
	DryFire2:
		SHRI A 0 A_GunFlash
		SHRI G 1 A_PlaySound("DRYFIRE", 1)
		SHRI GGGGGG 1 A_JumpIfInventory("StopDualWield", 1, "LightDone")
		Goto ReadyLoop

   Reload:
		"####" A 0 A_WeaponReady
		"####" A 0 A_ZoomFactor(1.0)
		"####" A 0 A_Takeinventory("Reloading",1)
		"####" A 0 A_Takeinventory("ADSmode",1)
		"####" A 0 A_Takeinventory("Zoomed",1)
		"####" A 0 A_JumpIfInventory("RifleAmmo",31,"ReadyLoop")
        "####" A 0 A_JumpIfInventory("Clip2",1,1)
       Goto NoAmmo
		"####" A 0 A_JumpIfInventory("TurboReload",1,"TurboReload")
		"####" A 0 A_Takeinventory("Zoomed",1)
        "####" A 0 A_PlaySound("Reload")
		//"####" A 0 A_GiveInventory ("Pumping", 1) // Mark copy+pastses a lot
		"####" A 0 A_Takeinventory("Reloading",1)
		RPFR ABCDE 2  A_JumpIfInventory("Kicking",1,"DoKick")
		"####" A 0 A_JumpIfInventory("HasUnloaded", 1, 2)
        "####" F 1 A_FireCustomMissile("EmptyClipSpawn",-5,0,8,-4)
        "####" GGGGGG 2
		"####" HIKL 2
		"####" MMMMM 1
		"####" NOPQRST 2 A_JumpIfInventory("Kicking",1,"DoKick")
		"####" A 0 A_Takeinventory("HasUnloaded",1)
		Goto Refill
		
	TurboReload:
		"####" A 0 A_Takeinventory("HasUnloaded",1)
		"####" A 0 A_JumpIfInventory("Clip2",1,"RefillTo30")
		Goto Ready
	
	Refill:
		TNT1 A 0 A_JumpIfInventory("RifleAmmo", 1, "RefillTo31") //CHeck which gun is not empty, as Reload2 is the case for BDDualPistolAmmo >= 1
		
	RefillTo30:
		TNT1 A 0 A_JumpIfInventory("Clip2", 1, 1)//Check if you have spare ammo again. This line is necessary in case you don't have enough ammo to fill an entire clip.
		Goto NoAmmo
		TNT1 A 0 A_TakeInventorY("Clip2", 1)//Removes one spare bullet
		TNT1 A 0 A_GiveInventory("RifleAmmo", 1)//Puts one bullet inside the clip
		TNT1 A 0 A_GiveInventory("DoubleRifleAmmo", 1)//Puts one bullet inside the clip
		TNT1 A 0 A_JumpIfInventory("RifleAmmo", 30, "FinishReload")
		Loop
		
	RefillTo31:
		TNT1 A 0 A_JumpIfInventory("Clip2", 1, 1)//Check if you have spare ammo again. This line is necessary in case you don't have enough ammo to fill an entire clip.
		Goto NoAmmo
		TNT1 A 0 A_TakeInventorY("Clip2", 1)//Removes one spare bullet
		TNT1 A 0 A_GiveInventory("RifleAmmo", 1)//Puts one bullet inside the clip
		TNT1 A 0 A_GiveInventory("DoubleRifleAmmo", 1)//Puts one bullet inside the clip
		TNT1 A 0 A_JumpIfInventory("RifleAmmo", 31, "FinishReload")//Checks if weapons is full
		Loop

	FinishReload:
		"####" A 0 A_Takeinventory("Reloading",1)
		"####" A 0 A_Refire
        Goto Ready
			
	Punch:
		TNT1 A 0 A_ChangeFlag("SHIELDREFLECT", TRUE)
		TNT1 A 0 A_TakeInventory("PunchCombo", 1)
		TNT1 A 0 A_Giveinventory("ReadyToQuickSlash",1)
		W01C A 1
		TNT1 A 0 A_PlaySound("WHOP")
		TNT1 A 0
		TNT1 A 0 SetPlayerProperty(0,1,0)
		W01C BC 2 //A_SpawnItemEx("ShieldDefense", 10,5,10,0,0,0,0,SXF_NOCHECKPOSITION,0)
		//TNT1 A 0 A_TakeInventory("SpecialAttackPunch2", 1)	// Doesn't do anything
		TNT1 A 0 A_Recoil(-12)
		TNT1 A 0 A_SpawnItemEx("ShieldDefense", 25,5,15,0,0,0,0,SXF_NOCHECKPOSITION,0)
		W01C D 1 A_FireCustomMissile("ShieldAttack", 0, 0, 0, -7)
		TNT1 A 0 A_JumpIfInventory("ShieldBashHappened",1,"BashConnect")
		W01C D 1 A_FireCustomMissile("ShieldAttack", 0, 0, 0, -7)
		TNT1 A 0 A_JumpIfInventory("ShieldBashHappened",1,"BashConnect")
		W01C E 1 A_FireCustomMissile("ShieldAttack", 0, 0, 0, -7)
		TNT1 A 0 A_JumpIfInventory("ShieldBashHappened",1,"BashConnect")
		W01C E 1 A_FireCustomMissile("ShieldAttack", 0, 0, 0, -7)
		TNT1 A 0 A_JumpIfInventory("ShieldBashHappened",1,"BashConnect")
		/*
		W01C F 0 A_FireCustomMissile("ShieldAttack", 40, 0, 0, -7)
		W01C F 0 A_FireCustomMissile("ShieldAttack", 20, 0, 0, -7)
		W01C F 0 A_FireCustomMissile("ShieldAttack", 0, 0, 0, -7)
		W01C F 0 A_FireCustomMissile("ShieldAttack", -20, 0, 0, -7)
		W01C F 0 A_FireCustomMissile("ShieldAttack", -40, 0, 0, -7)
		*/
	BashConnect:
		TNT1 A 0 SetPlayerProperty(0,0,0)
		W01C DCB 2
		TNT1 A 0 A_ChangeFlag("SHIELDREFLECT", FALSE)
		TNT1 A 0 A_TakeInventory("ShieldBashHappened",1)
		TNT1 A 0 A_GiveInventory("BashInhibitor",1)
		TNT1 A 0 A_JumpIfInventory("Kicking",1,"KickRight")
		W01C FGH 2 A_WeaponReady
		TNT1 A 0 A_JumpIfInventory("Kicking",1,"KickRight")
		Goto Ready
		
			// This can also be copy+pasted as long as a 30 shot rifle is involved
			// that uses the same ammo, having the sprites for the marine in the
			// code is going to be a little tacky, but it won't cause errors,
			// other coders will just know you copy+pasted. -Dino
	Unload:
		RPFG A 0 A_JumpIfInventory("IsPaladin",1,2)
		RIFG A 0
		"####" A 1 A_WeaponReady
		"####" A 0 A_ZoomFactor(1.0)
		"####" A 0 A_Takeinventory("Unloading",1)
		"####" A 0 A_Takeinventory("ADSmode",1)
		"####" A 0 A_Takeinventory("Zoomed",1)
        "####" A 0 A_JumpIfInventory("RifleAmmo",1,1)
        Goto NoAmmo
		RPFR A 0 A_JumpIfInventory("IsPaladin",1,2)
		RIFR A 0
		"####" A 0 A_Takeinventory("Zoomed",1)
		"####" TSRQPO 1
        "####" A 0 A_PlaySound("Reload")
		"####" A 0 A_Takeinventory("Unloading",1)
	RemoveBullets:
		"####" A 0 A_JumpIfInventory("RifleAmmo",1,1)
		Goto FinishUnload
		"####" A 0 A_Takeinventory("RifleAmmo",1)
		"####" A 0 A_Takeinventory("DoubleRifleAmmo",1)
		"####" A 0 A_Giveinventory("Clip2",1)
		Goto RemoveBullets
	
	FInishUnload:
		RPFR A 0 A_JumpIfInventory("IsPaladin",1,2)
		RIFR A 0
		"####" NMLKIGHGFEDCBA 1
		"####" A 0 A_PlaySound("DryFire")
		"####" A 0 A_GiveInventory("HasUnloaded", 1)
		"####" A 0 A_Takeinventory("Unloading",1)
		Goto Ready
	
	TossGrenade:
		"####" A 0 A_TakeInventory("TossGrenade", 1)
		"####" A 0 A_JumpIfInventory("GrenadeAmmo", 1, 1)
		Goto NoGrenade
		"####" A 0 A_Print("Can't throw grenades while dual wielding.")
		Goto ReadyLoop
	NoGrenade:
		"####" A 0 A_TakeInventory("TossGrenade", 1)
		"####" A 0 A_Print("No Grenades Left.")
		Goto ReadyLoop
		
		/*
		W01C F 0 A_FireCustomMissile("ShieldAttack", 40, 0, 0, -7)
		W01C F 0 A_FireCustomMissile("ShieldAttack", 20, 0, 0, -7)
		W01C F 0 A_FireCustomMissile("ShieldAttack", 0, 0, 0, -7)
		W01C F 0 A_FireCustomMissile("ShieldAttack", -20, 0, 0, -7)
		W01C F 0 A_FireCustomMissile("ShieldAttack", -40, 0, 0, -7)
		*/
	BashConnect:
		"####" A 0 SetPlayerProperty(0,0,0)
		W01C DCB 2
		"####" A 0 A_TakeInventory("ShieldBashHappened",1)
		"####" A 0 A_GiveInventory("BashInhibitor",1)
		"####" A 0 A_JumpIfInventory("Kicking",1,"KickRight")
		W01C FG 2 A_WeaponReady
		"####" A 0 A_JumpIfInventory("Kicking",1,"KickRight")
		Goto Ready
		
		Level2Punch:
		W01C F 0 A_Custompunch(random(30,50),1,1,"BrutalPunchPuff2", 150)
		W01C EDCB 2 A_WeaponReady
		W01C FG 2 A_WeaponReady
		Goto Ready
		
	 	AltFire:
	    TNT1 A 0
        "####" A 0 A_PlaySound("Paladin/MediumExert", 2)
		TNT1 A 0 A_PlaySound("WHOP")
	    TNT1 A 0 A_JumpIfInventory("PunchCombo", 1, "Punch")
		TNT1 A 0 A_JumpIfInventory("SpecialAttackPunch", 1, "Punch")
		W01D ABCDEFGH 1
		TNT1 A 0 A_Custompunch(random(60,120),1,1,"BrutalAxePuff", 125)
		TNT1 A 0 A_ChangeFlag("SHIELDREFLECT", TRUE)
		TNT1 A 0 A_Giveinventory("ReadyToQuickSlash",1)
		W01D IJK 2 A_SpawnItemEx("ShieldDefense", 25,5,15,0,0,0,0,SXF_NOCHECKPOSITION,0)
		
	AltHold:
	    "####" A 0
		"####" A 0 A_ChangeFlag("SHIELDREFLECT", TRUE)
	    SHRS E 1 A_SpawnItemEx("ShieldDefense", 25,5,15,0,0,0,0,SXF_NOCHECKPOSITION,0)
		"####" A 0 A_JumpIfInventory("TossGrenade",1,"TossGrenade")
		"####" A 0 A_JumpIfInventory("Kicking",1,"KickRight")
		"####" A 0 A_JumpIfInventory("SpecialAttackPunch", 1, "Punch")
		SHRS E 1
		SHRS E 1 A_Refire
		SHRS DDCBA 1 A_WeaponReady
		Goto ReadyLoop
	 
	Taunt:
        TNT1 A 0 A_Takeinventory("Zoomed",1)
        TNT1 A 0 A_ZoomFactor(1.0)
		FUCK K 1
		TNT1 A 0 BRIGHT A_FireCustomMissile("Taunter", 0, 0, -1, 0)
		TNT1 A 0 BRIGHT A_FireCustomMissile("Taunter", -9, 0, -1, 0)
		TNT1 A 0 BRIGHT A_FireCustomMissile("Taunter", 9, 0, -1, 0)
        FUCK L 1 A_PlaySound("FUCK", 2)
        FUCK MN 1 A_AlertMonsters
		FUCK O 15 A_Takeinventory("Taunting",1)
        FUCK NMLK 1
		Goto ReadyLoop
		
	Salute:
	    TNT1 A 0 SetPlayerProperty(0,1,0)
		TNT1 A 0 A_ALertMonsters
		SALU ABCDEDCDEDCDEDCBA 4
		TNT1 A 0 A_TakeInventory("Salute1",1)
		TNT1 A 0 A_TakeInventory("Salute2",1)
		TNT1 A 0 SetPlayerProperty(0,0,0)
		Goto Ready
		
	DualWield:
		RPFG A 1
		TNT1 A 0 A_Takeinventory("StartDualWield",1)
		TNT1 A 0 A_JumpIfInventory("DualRifles", 1, "GetDual")
		TNT1 A 0 A_Print("You must have two identical weapons to dual wield.")
		Goto Ready
		
	 GetDual:	
		TNT1 A 0 A_SetCrosshair(0)
		TNT1 A 0 A_Takeinventory("Zoomed",1)
		TNT1 A 0 A_Takeinventory("ADSmode",1)
		TNT1 A 0 A_TakeInventory("TossGrenade", 1)
		TNT1 A 0 A_TakeInventory("Kicking",1)
        TNT1 A 0 A_TakeInventory("Taunting",1)
        TNT1 A 0 A_TakeInventory("Reloading",1)
		TNT1 A 0 A_TakeInventory("Unloading",1)
		TNT1 A 0 A_TakeInventory("Salute1", 1)
		TNT1 A 0 A_TakeInventory("Salute2", 1)
        TNT1 A 0 A_ZoomFactor(1.0)
		TNT1 A 0 A_SelectWEapon("DualRifles")
		Goto Ready
	}
}

